<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<input type="text" id="usename" />
		<input type="checkbox" name="" id="remember" />记住用户名
		
		<script>
			var usename = document.querySelector('#usename');
			var remember = document.querySelector('#remember');
			if(localStorage.getItem('usename')){
				usename.value= localStorage.getItem('usename');
				remember.checked = true;
			}
			remember.addEventListener('click' , function(){
				if(this.checked){
					localStorage.setItem('usename' , usename.value)
				}else{
					localStorage.removeItem('usename');
				}
			})
		</script>
	</body>
</html>
